﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using DataModel;
using P_PersonalDetails.Service.MembershipDetails;
namespace P_PersonalDetails
{
    public partial class MembershipDetails : UserControl
    {
        public MembershipDetails()
        {
            InitializeComponent();
            try
            {
                MDS.GetMembershipDetailsCompleted += MDS_GetMembershipDetailsCompleted;
            }
            catch (Exception)
            {
            }
            
        }

        void MDS_GetMembershipDetailsCompleted(object sender, GetMembershipDetailsCompletedEventArgs e)
        {
            this.DataContext = new DataModels.MembershipDetailsDM(e.Result);
        }



        public int? MemberID
        {
            get { return (int?)GetValue(MemberIDProperty); }
            set { SetValue(MemberIDProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MemberID.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MemberIDProperty =
            DependencyProperty.Register("MemberID", typeof(int?), typeof(MembershipDetails), new PropertyMetadata(null, (DO, DE) => 
            {
                if (DE.NewValue != null)
                {
                    ((MembershipDetails)DO).MemberIDChanged();
                }
            }));

        void MemberIDChanged()
        {
            MDS.GetMembershipDetailsAsync(MemberID.Value);
        }

        #region Rich Text Box
        private void Unfocusable(object sender, RoutedEventArgs e)
        {
            BCUNoTextBox.Focus();
        }

        private void UpdateCursor(object sender, MouseEventArgs e)
        {
            ((Control)sender).Cursor = Cursors.Arrow;
        }
        #endregion


        MembershipDetailsServiceClient MDS = ServiceConfig.NewMembershipDetailsClient();
    }
}
